home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / iparam.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  4.5 KB  |  115 lines

  1. /* Copyright (C) 1993, 1995, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: iparam.h,v 1.2 2000/09/19 19:00:46 lpd Exp $ */
  20. /* Definitions and interface for interpreter parameter list implementations */
  21. /* Requires ialloc.h, istack.h */
  22.  
  23. #ifndef iparam_INCLUDED
  24. #  define iparam_INCLUDED
  25.  
  26. #include "gsparam.h"
  27.  
  28. /*
  29.  * This file defines the interface to iparam.c, which provides
  30.  * several implementations of the parameter dictionary interface
  31.  * defined in gsparam.h:
  32.  *      - an implementation using dictionary objects;
  33.  *      - an implementation using name/value pairs in an array;
  34.  *      - an implementation using name/value pairs on a stack.
  35.  *
  36.  * When reading ('putting'), these implementations keep track of
  37.  * which parameters have been referenced and which have caused errors.
  38.  * The results array contains 0 for a parameter that has not been accessed,
  39.  * 1 for a parameter accessed without error, or <0 for an error.
  40.  */
  41.  
  42. typedef struct iparam_loc_s {
  43.     ref *pvalue;        /* (actually const) */
  44.     int *presult;
  45. } iparam_loc;
  46.  
  47. #define iparam_list_common\
  48.     gs_param_list_common;\
  49.     gs_ref_memory_t *ref_memory; /* a properly typed copy of memory */\
  50.     union {\
  51.       struct {    /* reading */\
  52.     int (*read)(P3(iparam_list *, const ref *, iparam_loc *));\
  53.     ref policies;    /* policy dictionary or null */\
  54.     bool require_all;    /* if true, require all params to be known */\
  55.       } r;\
  56.       struct {        /* writing */\
  57.     int (*write)(P3(iparam_list *, const ref *, const ref *));\
  58.     ref wanted;        /* desired keys or null */\
  59.       } w;\
  60.     } u;\
  61.     int (*enumerate)(P4(iparam_list *, gs_param_enumerator_t *, gs_param_key_t *, ref_type *));\
  62.     int *results;        /* (only used when reading, 0 when writing) */\
  63.     uint count;        /* # of key/value pairs */\
  64.     bool int_keys        /* if true, keys are integers */
  65. typedef struct iparam_list_s iparam_list;
  66. struct iparam_list_s {
  67.     iparam_list_common;
  68. };
  69.  
  70. typedef struct dict_param_list_s {
  71.     iparam_list_common;
  72.     ref dict;            /* dictionary or array */
  73. } dict_param_list;
  74. typedef struct array_param_list_s {
  75.     iparam_list_common;
  76.     ref *bot;
  77.     ref *top;
  78. } array_param_list;
  79.  
  80. /* For stack lists, the bottom of the list is just above a mark. */
  81. typedef struct stack_param_list_s {
  82.     iparam_list_common;
  83.     ref_stack_t *pstack;
  84.     uint skip;            /* # of top items to skip (reading only) */
  85. } stack_param_list;
  86.  
  87. /* Procedural interface */
  88. /*
  89.  * For dict_param_list_read (only), the second parameter may be NULL,
  90.  * equivalent to an empty dictionary.
  91.  * The 3rd (const ref *) parameter is the policies dictionary when reading,
  92.  * or the key selection dictionary when writing; it may be NULL in either case.
  93.  * If the bool parameter is true, if there are any unqueried parameters,
  94.  * the commit procedure will return an e_undefined error.
  95.  */
  96. int dict_param_list_read(P5(dict_param_list *, const ref * /*t_dictionary */ ,
  97.                 const ref *, bool, gs_ref_memory_t *));
  98. int dict_param_list_write(P4(dict_param_list *, ref * /*t_dictionary */ ,
  99.                  const ref *, gs_ref_memory_t *));
  100. int array_indexed_param_list_read(P5(dict_param_list *, const ref * /*t_*array */ ,
  101.                      const ref *, bool, gs_ref_memory_t *));
  102. int array_indexed_param_list_write(P4(dict_param_list *, ref * /*t_*array */ ,
  103.                       const ref *, gs_ref_memory_t *));
  104. int array_param_list_read(P6(array_param_list *, ref *, uint,
  105.                  const ref *, bool, gs_ref_memory_t *));
  106. int stack_param_list_read(P6(stack_param_list *, ref_stack_t *, uint,
  107.                  const ref *, bool, gs_ref_memory_t *));
  108. int stack_param_list_write(P4(stack_param_list *, ref_stack_t *,
  109.                   const ref *, gs_ref_memory_t *));
  110.  
  111. #define iparam_list_release(plist)\
  112.   gs_free_object((plist)->memory, (plist)->results, "iparam_list_release")
  113.  
  114. #endif /* iparam_INCLUDED */
  115.